/**
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number}
 */

var maxDepth = function (root) {
    return fn(root)
    function fn(root) {
        if (!root) {
            return 0
        }
        return Math.max(fn(root.left) + 1, fn(root.right) + 1)
    }
};